const fs = require('fs');
const path = require('path');
const filePath = path.join(__dirname, '../source');
const languageObjModal = {
    "English": "en",
    "Chinese": "cn",
    "Bahasa Indonesia": "id",
    "Thai": "th",
    "Vietnamese": "vn",
    "Japanese": "jp",
    "Spanish": "es",
    "Portuguese": "pt"
}
//删除文件夹
function deleteFolderRecursive(path) {
    if (fs.existsSync(path)) {
        fs.readdirSync(path).forEach((file) => {
            const curPath = path + '/' + file;
            if (fs.lstatSync(curPath).isDirectory()) {
                deleteFolderRecursive(curPath);
            } else {
                fs.unlinkSync(curPath);
            }
        });
        fs.rmdirSync(path);
        console.log('文件夹删除成功');
    } else {
        console.error('文件夹不存在');
    }
}
function deleteAllProject() {
    // 遍历文件列表
    for (let key in languageObjModal) {
        const outputFilePath = path.join(__dirname, `../output/${languageObjModal[key]}`);
        deleteFolderRecursive(outputFilePath)
    }

    setTimeout(() => {
        // 遍历文件列表
        for (let key in languageObjModal) {
            const outputFilePath = path.join(__dirname, `../output/${languageObjModal[key]}`);
            fs.mkdirSync(outputFilePath)
        }
    }, 1000);
}

deleteAllProject()